//
//  BaseVC.m
//  JY_Project
//
//  Created by MAC on 2020/1/8.
//  Copyright © 2020 DLL. All rights reserved.
//

#import "BaseVC.h"

@interface BaseVC ()

@end

@implementation BaseVC

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self sendAlwaysAfNetwork];
    
    [self reloadNavigationBar];
}

/// 重载导航栏
-(void)reloadNavigationBar{

}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kBgColor;
    self.navigationController.navigationBar.hidden = YES;
    
    
    [self firstLoadData];
    [self firstUpdateView];
    [self sendAfNetwork];
}

//加载本地数据
-(void)firstLoadData{
    
}
//第一次载入页面
-(void)firstUpdateView{
    
}
//发送网络AF数据
-(void)sendAfNetwork{
    
}
-(void)sendAlwaysAfNetwork{
    
}

/// 请求成功后的处理
- (void)requestSuccess:(NSDictionary *)resDic{
    
}

/// 更新页面
-(void)endUpdateView{
    
}

/// 空白页面显示
-(void)showBlankView{
    
}

/// 更新无数据页面
- (void)endNoDataUpdateView{
}

/// 请求失败无数据页面
- (void)failUpdateView{

}

/**点击单元格响应方法*/
-(void)tableViewCellClickAction:(NSIndexPath *)indexPath{
    // 用于AOP监测点击事件用
}
-(void)collectionCellClickAction:(NSIndexPath *)indexPath{
    
}


-(void)endTableView:(UITableView *)tableView{
    [self.dataMarr removeAllObjects];
    if (tableView) {
        [tableView.mj_header endRefreshing];
        [tableView.mj_footer endRefreshing];
        [tableView reloadData];
        tableView.mj_footer.hidden = YES;
        self.curPage = @"1";
        self.pageSize = @"15";
    }
    self.view.userInteractionEnabled = YES;
}

-(void)endCollectionView:(UICollectionView *)collectionView{
    if (collectionView) {
        [collectionView.mj_header endRefreshing];
        [collectionView.mj_footer endRefreshing];
        [collectionView reloadData];
        collectionView.mj_footer.hidden = YES;
        self.curPage = @"1";
        self.pageSize = @"15";
    }
    [self.dataMarr removeAllObjects];
    self.view.userInteractionEnabled = YES;
}


#pragma mark -页面跳转
/// 进入下一级页面
- (void)zm_pushVC:(UIViewController *)vc{
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
/// 返回上一级
-(void)zm_popVC{
    [self.navigationController popViewControllerAnimated:YES];
}

/// 返回底部根视图
-(void)zm_popToRootVC{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

-(void)zm_presentVC:(UIViewController *)vc block:(void (^)(void))block{
    [self presentViewController:vc animated:YES completion:^{
        !block?:block();
    }];
}

-(void)zm_dismissVC:(void (^)(void))block{
    [self dismissViewControllerAnimated:YES completion:^{
        !block?:block();
    }];
}


@end
